package org.javaqq.face.main.lookandfeel;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.UIDefaults;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;

import org.javaqq.face.main.base.LightGrayFilter;

public class JavaQQLookAndFeel
    extends MetalLookAndFeel
{
    private static final long serialVersionUID = 0L;

    public boolean isNativeLookAndFeel() {
        return false;
    }

    public boolean isSupportedLookAndFeel() {
        return true;
    }

    public String getDescription() {
        return "The JavaQQ look and feel.";
    }

    public String getID() {
        return "JavaQQ";
    }

    public String getName() {
        return "JavaQQLookAndFeel";
    }


    protected void initClassDefaults(UIDefaults table) {
        super.initClassDefaults(table);

        String lfPackageName = "org.javaqq.face.main.lookandfeel.";

        Object[] uiDefaults = {
                "ButtonUI", lfPackageName + "JavaQQButtonUI",
                "ToggleButtonUI", lfPackageName + "JavaQQToggleButtonUI",
                "SplitPaneUI", lfPackageName + "JavaQQSplitPaneUI",
                "ScrollBarUI", lfPackageName + "JavaQQScrollBarUI",
                "ComboBoxUI", lfPackageName + "JavaQQComboBoxUI",
                "TextFieldUI", lfPackageName + "JavaQQTextFieldUI",
                "PasswordFieldUI", lfPackageName + "JavaQQPasswordFieldUI",
                "LabelUI", lfPackageName + "JavaQQLabelUI",
                "EditorPaneUI", lfPackageName + "JavaQQEditorPaneUI",
                "MenuItemUI", lfPackageName + "JavaQQMenuItemUI",
                "CheckBoxMenuItemUI", lfPackageName + "JavaQQCheckBoxMenuItemUI",
                "MenuUI", lfPackageName + "JavaQQMenuUI",
                "ToolBarUI", lfPackageName + "JavaQQToolBarUI",
                "ToolBarSeparatorUI", lfPackageName + "JavaQQToolBarSeparatorUI",
                "TabbedPaneUI", lfPackageName + "JavaQQTabbedPaneEnhancedUI",
                "ToolTipUI", lfPackageName + "JavaQQToolTipUI",
                "TextAreaUI", lfPackageName + "JavaQQTextAreaUI",
                "TextPaneUI", lfPackageName + "JavaQQTextPaneUI",
                "CheckBoxUI", lfPackageName + "JavaQQCheckBoxUI",
                "ListUI", lfPackageName + "JavaQQListUI",
                "PopupMenuUI", lfPackageName + "JavaQQPopupMenuUI",
                "SpinnerUI", lfPackageName + "JavaQQSpinnerUI"
        };
        table.putDefaults(uiDefaults);
    }

    public Icon getDisabledIcon(JComponent component, Icon icon) {
        if (icon instanceof ImageIcon) {
            return new IconUIResource(new ImageIcon(LightGrayFilter.
                   createDisabledImage(((ImageIcon)icon).getImage())));
        }
        return null;
    }
}
